package com.gaolang.util;

import org.springframework.util.ResourceUtils;

import java.io.*;

public class MedInfo {
    /**
     * 根据药品名称返回药品简介
     * @param name
     * @return
     */
    public static String getInfo(String name) throws IOException {
        BufferedReader br = new BufferedReader(new FileReader(ResourceUtils.getFile("classpath:药材简介.txt")));
        String line=br.readLine();
        while (!line.trim().equals(name)){
            line=br.readLine();
        }
        StringBuilder sb=new StringBuilder();
        while (!line.trim().equals("")){
            line=br.readLine();
            sb.append(line);
        }
        br.close();
        return sb.toString();
    }
}
